home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 8
/
Aminet 8 (1995)(GTI - Schatztruhe)[!][Oct 1995].iso
/
Aminet
/
util
/
boot
/
RNDBackdrop.lha
/
RNDBackdrop
/
ScanPicDir
< prev
next >
Wrap
Text File
|
1995-08-08
|
3KB
|
115 lines
/* ScanPicDir - Scans for WB Backdrops and writes them in a file
**
** By Reinhard Katzmann suamor@student.uni-tuebingen.de
**/
version='$VER: ScanPicDir 1.0 (8.8.95)
'
SIGNAL ON BREAK_D
SIGNAL ON BREAK_C
OPTIONS RESULTS
if ~show('L', 'rexxdossupport.library') then /* Just for ReadArgs() */
call addlib('rexxdossupport.library',0,-30)
if ~show('L', 'rexxarplib.library') then /* For FileList() */
call addlib('rexxarplib.library',0,-30) /* and Getenv() */
/* Parse arguments */
/* Usage: ScanPicDir Paths/M,Pattern/K,ALL/S,DIR/S,Outfile/K */
parse arg args
template = 'Paths/M,Pattern/K,ALL/S,DIRS/S,FILES/S,Outfile/K'
Paths.count=0
Paths.0=''
ALL=1
DIRS=0
FILES=0
Outfile="sys:t/backdrops"
Pattern='~(#?.info)'
numfiles=0
if (args=='?') then do
writech(stdout,template': ')
parse pull moreargs
if (moreargs=='?') then do
say "ScanPicDir"
say "By Reinhard Katzmann suamor@student.uni-tuebingen.de"
say version
say ""
say "Usage: ScanPicDir "template
say ""
say ' You do not need to put a "/" at the end of the Path.'
say " You can give several dirs as arguments"
say ""
say "Example:"
say " RX ScanPicDir sys:prefs/presets/backdrops"
say " scans the dir and writes contents to sys:t/backdrops"
exit
end
else args=moreargs
end
ReadArgs(args,template)
if Paths.count=0 then do
Paths.count=1
Paths.0=''
end
SELECT /* options for showdir() */
when ALL then option=''
when DIRS then option='D'
when FILES then option='F'
OTHERWISE option=''
END
/* Main Program */
do i=0 to (Paths.count-1)
IF (~exists(Paths.i)) then do /* Can't find Path */
say "Can't find Path "Paths.i
exit
END
if (Paths.i~='') then do
trim(Paths.i) /* Check for / or : at end of Path and add one*/
IF (right(Paths.i, 1) ~= '/')&(right(Paths.i,1)~=':') then do /* if not already there. */
Paths.i = Paths.i'/'
END
end
num = FileList(Paths.i''Pattern, afile, option, 'e') /* 'e' causes it to return */
/* the full path */
do loop=1 to num
numfiles=numfiles+1
thefile.numfiles=afile.loop
end
end /* do loop */
if numfiles=0 then do
say "Error: Directory is empty"
exit
end
else do
if (Open('fp',Outfile,'W')) then do until numfiles=0
name=thefile.numfiles
writeln('fp',name)
numfiles=numfiles-1
end
else do
say "Could not open Outfile" Outfile" for writing."
exit
end
end
Close('fp')
say "File "Outfile" succesfully written"
BREAK_D:
exit
BREAK_C:
exit